<!DOCTYPE html>
<!-- This test should not be upstreamed due to shift-reload behavior
is not defined by spec. -->
<title>Service Worker: force-refresh ready test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.js"></script>
<body>
<script>

promise_test(function(t) {
    var scope = 'resources/blank.html';
    var script_url = 'resources/empty-worker.js';
    var frame;
    return service_worker_unregister_and_register(t, script_url, scope)
      .then(function(registration) {
          return wait_for_state(t, registration.installing, 'activated');
        })
      .then(function() {
          return with_iframe(scope);
        })
      .then(function(f) {
          frame = f;
          return new Promise(function(resolve) {
              frame.onload = t.step_func(function() {
                  frame.contentWindow.navigator.serviceWorker.ready
                    .then(function() {
                        resolve();
                      });
                });
              frame.contentWindow.internals.forceReload(true);
            });
        })
      .then(function() {
          frame.remove();
          return service_worker_unregister_and_done(t, scope);
        });
  }, 'Test ready promise for force-refreshed frame');

</script>
</body>
